/*******************************************************************************
 * Homework 4: Main4.cpp, CSCE 240, Spring 2010
 * Author: Andrew Shore
 * Date Last Modified: 1 March 2010
 *
 * Overview of Program: This program takes two input files, one a matrix of
 * characters like those found in a typical wordsearch puzzle and another being
 * a list of words to be searched for in the matrix. The program allows for 
 * toroidal wrapping of words so there is modular wraparound in all directions.
 * Once words are found they are displayed in an output file along with the
 * original wordsearch matrix and list of words. 
 *
 * Description of Main: The main intializes and opens two input streams and one
 * output stream. The names of the files are recieved from the command line and
 * Duncan Buell's Utils program is used to open the files with the function
 * FileOpen. The CheckArgs function is used to ensure that the correct number  
 * of file names are passed to the program. An instance of the Wordsearch class 
 * is declared and the input and output streams are passed to the initialize
 * function of Wordsearch. After the search is done the input and output 
 * streams are closed.
 * 
 * Input: None
 *
 * Output: a log of what occurs sent to the output file
 *
 * Includes Main4.h and Utils.cpp.
*******************************************************************************/

#include "Main4.h"
#include "Utils.cpp"
using namespace std;

int main(int argc, char *argv[]){
  
  ifstream arrIn;
  ifstream wordsIn;
  ofstream outStr;
   
  Wordsearch wordsearch;

  Utils::CheckArgs(3, argc, argv,  "zarrayinput zwordsinput zoutput");

  //opens input streams, checks to make sure input filename is valid
  Utils::FileOpen( arrIn, string(argv[1]) );
  Utils::FileOpen( wordsIn  , string(argv[2]) );
  Utils::FileOpen( outStr, string(argv[3]) );

  wordsearch.initialize( arrIn, wordsIn, outStr);

  //closes file streams
  Utils::FileClose(arrIn);
  Utils::FileClose(wordsIn);
  Utils::FileClose(outStr);

  return 0;

}
